package day04;

/**
 * @author yangwenqi
 * @decs TODO
 * @date 2025/4/19
 */
public class Test05 {
    public static void main(String[] args) {
        int[][] a = {{1,2,3},{4,5,6},{7,8,9}};
        int sum = 0;
        //主对角线元素之和
        for (int i = 0; i < a.length; i++) {
            for (int j = 0; j < a[i].length; j++) {
                //主对角线之和
                if(i==j){
                    sum+=a[i][j];
                }
                //副对角线之和
                if(i+j==a.length-1){
                    sum+=a[i][j];
                }
            }
        }
        System.out.println(sum-a[a.length/2][a.length/2]);
    }
}
